﻿namespace ZXAPP.Views
{
    public partial class SplashPage : ContentPage
    {
        public string serverAddress { get; set; }
        int count = 0;
        // 在类的定义中添加一个Timer对象，其回调函数是OnTimer方法
        System.Timers.Timer timer;
        public SplashPage()
        {
            
            InitializeComponent();            

            ////从preference 中获取默认的浏览地址
            //serverAddress = Preferences.Get("SERVER", "168.168.100.125:10000");
            //timer = new System.Timers.Timer(3000); // 设置间隔为3秒
            //timer.Elapsed += OnTimer; // 设置回调函数为OnTimer
            ////timer.AutoReset = true; // 设置自动重置为true，使得定时器可以多次触发
            //timer.Enabled = true; // 启动定时器

            //this.BindingContext = this;
        }

        private async void OnSettingClicked(object sender, EventArgs e)
        {
            timer.Stop();
            //显示隐藏的三个控件，隐藏原来的登录倒数
            WellcomeGroup.IsVisible = false;    
            SettingGroup.IsVisible = true;
            //await Shell.Current.GoToAsync("//webpage");
        }
        //添加一个定时器计时3秒后跳转到主页
        private async void OnTimer(object sender, EventArgs e)
        {
             await Shell.Current.GoToAsync("//webpage");
        }
        private async void OnLogonClicked(object sender, EventArgs e)
        {
            //保存设置的服务器地址
            Preferences.Set("SERVER", serverAddress);
            await Shell.Current.GoToAsync("//webpage");
        }
    }

}
